{include(head.tpl)}
<body>
<div class="wrapper-content">
    <div class="animated fadeInDown wrap">
        <div class="btn-box">
            <span class="dib padding-5 radius-3 blue addcolumn">添加栏目</span>
        </div>
        <table class="table_value table">
            <tr>
                <th>ID</th>
                <th>栏目代码</th>
                <th>栏目名称</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            {foreach from=listarr item=vo}
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.colcod}</td>
                    <td>{$vo.colname}</td>
                    <td><?php echo date('Y-m-d H:i:s',$vo['addtime']) ;?></td>
                    <td>
                      <span class="dib padding-5 radius-3 orange_2" onclick="editcolumn({$vo.id})">编辑</span> <span onclick="delcolumn({$vo.id})" class="dib padding-5 radius-3 orange">删除</span>
                    </td>
                </tr>
            {/foreach}
        </table>
        <div class="page">{pageshow}</div>
    </div>
</div>


<script>
//分页
function ajaxpage(page){
    var url='page='+page;
    _ajaxs.post('{mothedurl}',url,function _return(hdata){
        var pageh=pagehead();
        var pagec=pagecontent(hdata);
        $('.table_value').html('');
        $('.table_value').html(pageh+pagec);
        $('.page').html('');
        $('.page').html(hdata.data.pageshow);
    })
}
function pagehead(){
    var pageheadhtml='<tr>\
        <th>ID</th>\
        <th>栏目代码</th>\
        <th>栏目名称</th>\
        <th>创建时间</th>\
        <th>操作</th>\
    </tr>';
    return pageheadhtml;
}
function pagecontent(hdata){
    var list=hdata.data.list;
    var pagecontenthtml='';
    if(list!=''){
      for(i=0;i<list.length;i++){
        pagecontenthtml+='<tr>\
          <td>'+list[i]['id']+'</td>\
          <td>'+list[i]['colcod']+'</td>\
          <td>'+list[i]['colname']+'</td>\
          <td>'+_myTime.UnixToDate(list[i]['addtime'],true,8)+'</td>';
        pagecontenthtml+='<td>\
          <span class="dib padding-5 radius-3 orange_2" onclick="editcolumn('+list[i]['id']+')">编辑</span>\ <span onclick="delcolumn('+list[i]['id']+')" class="dib padding-5 radius-3 orange">删除</span>\
        </td>';
        pagecontenthtml+='</tr>';
      }
    }
    return pagecontenthtml;

}
    $(function(){
      //添加栏目
      $('.addcolumn').click(function(){
          layer.open({
            type: 2,
            title: '添加栏目',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['300px', '300px'],
            content:'{ctlurl}/columnAdd',
        });
      })
    })
    //添加--编辑栏目时弹窗回调
    function addcoumn_layer(){
      layer.close(layer.index);
      window.location.reload();
    }
    //编辑栏目
    function editcolumn(id){
      layer.open({
          type: 2,
          title: '编辑栏目',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['300px', '300px'],
          content:'{ctlurl}/columnEdit/id/'+id,
      });
    }
    function delcolumn(id){
        var delcolumn_layer=layer.confirm('确认要删除吗！', {btn: ['确认','取消'],'title':'删除栏目'},function(){
              _ajaxs.post('{ctlurl}/columnDel','id='+id,function _return(hdata){
                  if(hdata.status){
                    layer.msg(hdata.msg,function(){
                        window.location.reload();
                    });
                  }else{
                    layer.msg(data.msg);
                  }
              })
        },function(){
          layer.close(delcolumn_layer);
        });
    }
</script>
</body>
</html>
